<template>
  <page-frame>
    <div class="package-change-01">
      <div class="toptitle">
        <div class="left">外部会员-{{member.memberName}} -制定服务计划</div>
        <div class="right">
          <div class="btns">
            <!--<el-button @click="submit" class="lightGreenBtn">保存</el-button>-->
            <el-button @click="back">返回</el-button>
          </div>
        </div>
      </div>
      <div class="borderT"></div>
      <div class="external-plan">
        <div>
          <div class="bar"></div>
          <div class="make-plan">
            <planMake :member="member"  :isChange="false" :way="externalMemPlan"></planMake>
          </div>
        </div>
      </div>
    </div>
  </page-frame>
</template>

<script>
  import planMake from '../../components/assessment/planMake.vue';
  import commonApi from '../../service/member/commonApi';
  import packageChangeApi from '../../service/member/packageChangesApi';
  export default {
    methods: {
      init(){
        this.getAllMember();
        this.getCareLevel();
      },
      /**
       * 加载
       */
      loadTableData(){

      },
      /**
       * 返回
       */
      back(){
//        this.$confirm('是否返回上级页面，点击「确认」后将不保存当页内容', '返回', {
//          confirmButtonText: '确定',
//          cancelButtonText: '取消',
//          type: 'warning'
//        }).then(() => {
//          this.$message({
//          type: 'success',
//          message: '返回成功!'
//        });
//        this.$router.push({name: "memberFile"});
//      }).catch(() => {
//          this.$message({
//          type: 'info',
//          message: '已取消返回'
//        });
//      });
        this.$router.push({name: "homeBased"});
      },
      /**
       * 提交申请
       */
      submit(){
        this.$confirm('确认提交会员 ' + this.memberName + ' 的套餐变更申请', '套餐变更申请', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '提交成功!'
          });
          this.$router.push({name: "memberFile"});
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消申请'
          });
        });

      },
      /**
       * 筛选会员
       */
//      querySearchAsync(queryString, cb) {
//        var members = this.members;
//        if(members instanceof Array){
//          var results = queryString ? members.filter(this.createStateFilter(queryString)) : members;
//          clearTimeout(this.timeout);
//          this.timeout = setTimeout(() => {
//            cb(results);
//          }, 1000);
//        };
//      },
//      createStateFilter(queryString) {
//        return (state) => {
//          return (state.memberName.indexOf(queryString.toLowerCase()) === 0);
//        };
//      },
//      handleSelect(item) {
//        this.memberInfor = item;
//        console.debug(this.memberInfor);
//        this.form.memberId = item.memberId;
//        this.form.bedId = item.bedId;
//        this.memberId=item.memberId;
//        this.getLastedAssessment(1,item.memberId);
//      },
      /**
       * 获得评估项目表格数据
       */
      getLastedAssessment(sheetType,memberId){
        packageChangeApi.getLastedAssessment(sheetType,memberId).then(
          (response)=>{
            this.assessItem = response.data.data.setResultInfoDTOList;
            this.assessmentResult=response.data.data.assessmentResultDTO;
            this.assessmentResult.auditTime=this.assessmentResult.auditTime.substring(0,16);
            for(let i=0;i<this.assessItem.length;i++){
              this.totalScore =this.totalScore+this.assessItem[i].resultValue;
            }
          }
        );
      },
      /**
       * 获得所有会员
       */
      getAllMember(){
        let self = this;
        commonApi.getAllCheckInMemberInfor().then(function (response) {
          self.members = response.body.data;
          for(var i=0;i<self.members.length;i++){
            var  member = self.members[i];
            member.value = member.memberName;
          };
        })
      },
      /**
       * 获得照护等级
       */
      getCareLevel(){
        commonApi.getCareGrade().then(
          (response)=>{
            this.careLevelOptions = response.data.data;
          }
        );
      },
    },
    beforeMount: function () {
      this.member = this.$route.params.memberObj;
      this.memberId = this.member.memberId;
    },
    mounted: function () {
      this.init();
    },
    data() {
      return {
        stepData: 1,
        tableData: [],
        totalScore:0,
        memberName:"",
        externalMemPlan:"externalMemPlan",
        form: {},
        memberInfor:{},
        members:[],
        assessItem: [],
        assessmentResult:{},
        newGrade:'',
        careLevelOptions:[],
        memberId:'',
        member:{},
      }
    },
    components: {
      planMake
    },
  }
</script>
<style>

  .external-plan .Application {
    /*width: 70%;*/
    /*margin: 0px auto;*/
    /*padding-left: 30px;*/
  }

  .external-plan .bar {
    /*margin: 35px 0;*/
  }

  .external-plan .verticalBar {
    display: inline-block;
    width: 5px;
    height: 25px;
    vertical-align: middle;
    background-color: #0cb7c6;
  }

  .package-change-01 .Application {
    /*width: 80%;*/
    /*margin: 0 auto;*/
    /*padding-left: 30px;*/
  }

  .package-change-01 .Application .bar {
    margin-bottom: 18px;
    margin-top: 50px;
  }

  .package-change-01 .Application .review .reviewItem {
    height: 36px;
    line-height: 36px;
    width: 100%;
    background-color: #eef1f6;
    margin-bottom: 5px;
  }

  .package-change-01 .Application .tabs-result-assessment{
    margin: 15px 0;
  }

  .package-change-01 .lInfro{
    font-size: 13px;
  }

  .package-change-01 .lInfro span{
    margin-left: 5px;
  }
  .package-change-01 .lInfro .el-select{
    width: 60%!important;
    margin-left: 5px;
  }

  .package-change-01 .lInfro .labelTotal{
    display:inline-block;
    height:36px;
    line-height:36px;
  }

  .package-change-01 .lInfro.memberNo{
    height:36px;
    line-height:36px;
  }

  .package-change-01 .totalScore{
    display:inline-block;
    height:36px;
    width:100px;
    line-height:36px;
  }
</style>


